<template>
  <div>
    <Dog
      v-for="(obj, index) in arr"
      :key="index"
      :imgurl="obj.dogImgUrl"
      :dogname="obj.dogName"
      @love="fn"
    ></Dog>

    <hr />
    <p>显示喜欢的狗:</p>
    <ul>
      <li v-for="(item, index) in loveArr" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
import Dog from "@/practise/Dog4";
export default {
  data() {
    return {
      // 1. 准备数据
      arr:[
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=3332251293,4211134448&fm=193&f=GIF",
        dogName: "小狗",
    },
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=1831997705,836992814&fm=193&f=GIF",
        dogName: "小鸟",
    },
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=762377413,2049607695&fm=193&f=GIF",
        dogName: "小猫",
    },
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=2471051649,2314656574&fm=193&f=GIF",
        dogName: "仓鼠",
    },
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=3945220250,2602371635&fm=193&f=GIF",
        dogName: "乌龟",
    },
    {
        dogImgUrl:
        "https://t7.baidu.com/it/u=2587978747,4268841661&fm=193&f=GIF",
        dogName: "兔子",
    },
],
      loveArr: []
    };
  },
  components: {
    Dog,
  },
  methods: {
    fn(dogName) {
      this.loveArr.push(dogName)
    },
  },
};
</script>

<style >
</style>